import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { Cache } from "../../cache/Cache";
import { MsgManager } from "../../manager/MsgManager";
import { ECategory } from "../../../../Message/Public/ECategory";
import { EProp } from "../../../../Message/Public/EProp";
import { QuickBuyWindow } from "../common/QuickBuyWindow";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class GuildImpeachWindow
    
    export  class GuildImpeachWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(385, 270);
            this.titleHeight = 28;
            this.title = Language.getString(57405);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(17, 39, 350, 180, this);
            this._tipTxt = ObjCreate.createTextField("", 30, 50, 320, 220, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.multiline = true;
            this._tipTxt.wordWrap = true;
            this._tipTxt.htmlText = Language.getString(57406);
            this._impeachBtn = ObjCreate.createGButton(Language.getString(57407), 135, 225, 115, 28, this, "ButtonSpecial");
            this._impeachBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onImpeachBtnClickHandler);
            return;
        }

        public updateImpeachBtn(arg1: Boolean): void
        {
            this._impeachBtn.enabled = arg1;
            return;
        }

        /* internal  */onImpeachBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            if (Cache.instance.guild.isInImpeaching) 
            {
                MsgManager.showRollTipsMsg(Language.getString(57427));
                return;
            }
            var loc1=Cache.instance.pack.backPackCache.getItemCountByCategoryAndType(ECategory._ECategoryProp, EProp._EPropGuildLeaderImpeach);
            if (loc1 == 0) 
            {
                QuickBuyWindow.instance.updateWindow(ECategory._ECategoryProp, EProp._EPropGuildLeaderImpeach);
                QuickBuyWindow.instance.updateDefaultAmount(1);
                QuickBuyWindow.instance.show();
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildImpeachLeader));
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildGetCanImpeach));
            return;
        }

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_impeachBtn: GButton;
    }
